package com.google.demo.Activity;

import com.google.demo.R;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.Button;

public class UIBottomButtonsHelper {
	private Activity _activity;

	public Button _btnScan = null;
	public Button _btnHistory = null;
	public Button _btnSetting = null;

	public static final int OTHER = 0;
	public static final int SCAN_SCREEN = 10;
	public static final int HISTORY_SCREEN = 50;
	public static final int SETTING_SCREEN = 100;
	
	//QUAN LY VIEC CLICK 4 BUTTON BEN DUOI, TUONG UNG VOI 4 MAN HINH: Nearby, Place, Reward, Me.
	public static int CURRENT_SCREEN_OF_4_MAINSCREEN = SCAN_SCREEN;
	
	
	
	public UIBottomButtonsHelper(Activity _activity) {
		this._activity = _activity;
		if (this._activity != null) {
			this._btnScan= (Button) this._activity.findViewById(R.id.button_scan);
			this._btnHistory = (Button) this._activity.findViewById(R.id.button_histories);
			this._btnSetting = (Button) this._activity.findViewById(R.id.button_setting);
		}
	}

	public void disableAllButtons() {
		_btnScan.setEnabled(false);
		_btnHistory.setEnabled(false);
		_btnSetting.setEnabled(false);
		
	}

	public void enableAllButtons() {
		_btnScan.setEnabled(true);
		_btnHistory.setEnabled(true);
		_btnSetting.setEnabled(true);
	}

	
	
	public void updateFooterButton()
	{
		Drawable da_image;
		da_image = _activity.getResources().getDrawable(R.drawable.scan_btn);
		this._btnScan.setBackgroundResource(R.drawable.footer_bg);		
		this._btnScan.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
		
		da_image = _activity.getResources().getDrawable(R.drawable.histories_btn);
		this._btnHistory.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
		this._btnHistory.setBackgroundResource(R.drawable.footer_bg);
		
		da_image = _activity.getResources().getDrawable(R.drawable.setting);
		this._btnSetting.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
		this._btnSetting.setBackgroundResource(R.drawable.footer_bg);
		
		
		switch (CURRENT_SCREEN_OF_4_MAINSCREEN) {
		case SCAN_SCREEN:
			this._btnScan.setBackgroundResource(R.drawable.footer_over);
			da_image = _activity.getResources().getDrawable(R.drawable.scan_btn_active);
			this._btnScan.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
			break;
		
		case SETTING_SCREEN:
			this._btnSetting.setBackgroundResource(R.drawable.footer_over);
			da_image = _activity.getResources().getDrawable(R.drawable.setting_active);
			this._btnSetting.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
			break;

		case HISTORY_SCREEN:
			this._btnHistory.setBackgroundResource(R.drawable.footer_over);
			da_image = _activity.getResources().getDrawable(R.drawable.histories_btn_active);
			this._btnHistory.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
			break;
		default:
			this._btnScan.setBackgroundResource(R.drawable.footer_over);
			da_image = _activity.getResources().getDrawable(R.drawable.scan_btn_active);
			this._btnScan.setCompoundDrawablesWithIntrinsicBounds(null, da_image, null, null);
			break;
		}
	}
}
